import sensor from '@system.sensor';
import {jsCallJavaAbility} from "../../common/JsCallJavaAbilityUtils.js"

export default {
    data: {
        question: "",
        after_heart: []
    },
    sendHeartData() {
        jsCallJavaAbility.callAbility("com.panda_coder.linedetector.watch.ConnectServiceAbility", 101, {
            "hearts": this.after_heart
        })
    },
    onInit() {
        this.$watch('after_heart', 'sendHeartData');
    },
    onShow() {
        sensor.subscribeHeartRate({
            success: (ret) => {
                this.after_heart.push(ret.heartRate)
            },
            fail: (data, code) => {
                console.log(code)
            }
        })
    },
    onDestroy() {
        sensor.unsubscribeHeartRate()
    }
}
